/**
 *格式化字符串
 *@method format
 *@param {string} format字符
 *@format {object} 对象或数组
 *@format {string} ，号隔开，字符串
 *return 格式化的之后的字符串
 *{code}
 *  format("{0}格式", 1); //  "1格式"
 *  format("{1}格式",0,1); // "1格式"
 *  format("{a}格式",{a:"也可以"}); // 也可以格式
 *  format("{{0}}不转换, {1}转换", 0,1); //  "{0}不转换,1转换"
 *{code}
 */
function format(format,object){
	if(format===""||format===null){
		return "";
	}
	var arr=(is(object,"Object")&&arguments.length===2)?object:Array.prototype.slice.call(arguments,1),
		reg=/\{(\w*?)\}/g;
	//格式化返回	
	return format.replace(reg,function(match,name){
		return name in arr?arr[name]:"";			 
	});
}
/**
 *判断一个变量类型
 *@method is
 *@param {type} 变量
 *@param {string} 字符串首字母大写
 *return Boolean
 *{code}
 *	is(5,"Number");      true
 *	is({},"Object");     true 
 *	is([],"Array");      true
 *	is(/foo/,"RegExp");  true
 *	is("","String");     true
 *	is(undefined,"Undefined");   true
 *	is(null,"Null");     true
 *	is(s1.callback,"Function");  true, IE BUG
 *	is(function(){},"Function"); true
 *{code}
 */
function is(obj,type){
	return (obj===null&&type==='Null')||
		   (obj===undefined&&type==='Undefined')||
		   (type==='Function'&&"object"===typeof document.getElementById?
			/^\s*\bfunction\b/.test(""+obj):
		Object.prototype.toString.call(obj).indexOf(type)>-1);
}
/**
 *去掉字符串的空格
 *@method trim
 *@param {String} 字符串
 *@param {string}  left，right，all
 *return String;
 *[code]
 *  trim("string","left");
 *  trim("string","all");
 *  trim("string","right");
 *[code]
 */
 function trim(source,type){
	 if(!source){return source;};
	 if(!type){type="all"};
	 var reg;
	 switch(type){
	 	case "all":
			reg=/\s*/;
		break;
		
	 }
	 return source.replace(reg,"");
 }
